package com.tjetc;

import java.util.Date;

public class _2ExceptionExercise {

    public static void main1(String[] args) {
        // 类型转换
        Object obj = new Date();
        _2ExceptionExercise test;
        test = (_2ExceptionExercise) obj;
        System.out.println(test);
    }

    int x;
    public static void main(String[] args) {
        // 算术异常
        int y;
        _2ExceptionExercise test = new _2ExceptionExercise();
        y = 3 / test.x;
        System.out.println("end");

    }

    public static void main3(String[] args) {
        // 空指针
        Cat cat = new Cat();
        cat = null;
        System.out.println(cat.name);

    }
    public static void main2(String[] args) {
        // 数组越界
        String[] friends = {"zhangsan", "lisi"};
        for (int i = 0; i <= friends.length; i++) {
            System.out.println(friends[i]);
        }
    }
}

class Cat {
    String name;
}
